// pages/company/company.ts
const app = getApp()
const baseurl = app.globalData.baseurl
const token = wx.getStorageSync('token')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    baseurl:baseurl,
    fuli: [
      { src: "../../image/时间.png", name: "9:00-18:00" },
      { src: "../../image/双休.png", name: "双休" },
      { src: "../../image/保险.png", name: "五险一金" },
      { src: "../../image/医疗.png", name: "医疗保险" },
      { src: "../../image/年终奖.png", name: "年终奖" },
      { src: "../../image/餐补.png", name: "餐补" },
      { src: "../../image/车.png", name: "免费班车" },
    ],
  },
  // 获取公司详情
  getcompany(id) {
    wx.request({
      url: baseurl + '/company/get',
      method: 'GET',
      data: { id: id },
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token'),
      },
      success: res => {
        var currentDate = new Date();
        var yearDiff = currentDate.getFullYear() - new Date(res.data.data.data).getFullYear();
        console.log(res.data.data,yearDiff)
        this.setData({
          company:res.data.data,
          yearDiff:yearDiff
        })
      }
    })
  },
  getcompanyjob(id) {
    wx.request({
      url: baseurl + '/job/getCompany',
      method: 'GET',
      header: {
        'Authorization': 'Bearer ' + wx.getStorageSync('token'),
      },
      data: {
        id: id
      },
      success: res => {
        console.log(res.data)
        this.setData({
          filteredItems: res.data.data
        })
      }
    })
  },
  tiaozhuan: function (e) {
    // var id = contentList[e.currentTarget.dataset.id].id
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/item/item?id=${id}`,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const id = options.id
    this.getcompany(id)
    this.getcompanyjob(id)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})